package com.management.controller;


import com.management.controller.form.*;
import com.management.service.DefectStateService;
import com.management.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 龙世超
 * @since 2022-03-23
 */
@RestController
@Api(tags = "缺陷状态相关操作")
@RequestMapping("/defectState")
public class DefectStateController {


    @Resource
    private DefectStateService defectStateService;

    /**
     * 获取状态并分页
     * @param getStatePageForm
     * @return
     */
    @ApiOperation("获取状态并分页")
    @PostMapping("/GetState")
    public Result GetStates(@RequestBody GetStatePageForm getStatePageForm){
        return defectStateService.FindStates(getStatePageForm);
    }

    /**
     * 新增状态
     * @param createStateForm
     * @return
     */
    @ApiOperation("新增状态")
    @PostMapping("/CreateState")
    public Result CreateState(@RequestBody CreateStateForm createStateForm){
        return defectStateService.CreateState(createStateForm);
    }

    /**
     * 根据状态Id逻辑删除状态
     * @param removeStateForm
     * @return
     */
    @ApiOperation("根据状态Id逻辑删除状态")
    @PostMapping("/removeStateBystateId")
    public Result removType(@RequestBody RemoveStateForm removeStateForm){
        return defectStateService.removState(removeStateForm);
    }

    /**
     * 根据状态Id批量删除状态
     * @param removeBysateIdsForm
     * @return
     */
    @ApiOperation("根据状态Id批量删除状态")
    @PostMapping("/removeBystateIds")
    public Result removeBytypeIds(@RequestBody RemoveBysateIdsForm removeBysateIdsForm){
        return defectStateService.removeBystateIds(removeBysateIdsForm);
    }

    /**
     * 禁用某状态
     * @param disableStateForm
     * @return
     */
    @ApiOperation("禁用某状态")
    @PostMapping("/disableBystateId")
    public Result disableBytypeId(@RequestBody DisableStateForm disableStateForm){
        return defectStateService.updateBystateId(disableStateForm);
    }

    /**
     * 获取所有状态
     * @return
     */
    @ApiOperation("获取所有状态")
    @GetMapping("/GetAllDefectState")
    public Result GetAllDefectState(){
        return defectStateService.FindAllDefectState();
    }

    /**
     * 获取所有缺陷状态占比
     * @return
     */
    @ApiOperation("获取所有缺陷状态占比")
    @GetMapping("getAllDefect")
    public Result getAllState(){
        Result allDefect = defectStateService.getAllDefect();
        return allDefect;
    }

}

